<template>
  <!-- 清算账户资金池管理审核明细页面弹出框-->
  <el-dialog
    title="清算账户资金池管理审核明细"
    center
    :visible.sync="open"
    width="1024px"
    :close-on-click-modal="false"
    @close="closeFn"
  >
    <el-form ref="detailsForm" :model="formData" label-width="170px">
      <el-row type="flex">
        <el-col :span="12">
          <el-form-item label="交易流水号：" prop="id">
            <el-input v-model="formData.id" placeholder="交易流水号" disabled />
          </el-form-item>
        </el-col>
        <el-col :span="12"></el-col>
      </el-row>

      <el-row type="flex">
        <el-col :span="12">
          <el-form-item label="CPG日期：" prop="vdate">
            <el-date-picker
              disabled
              v-model="formData.vdate"
              type="date"
              value-format="yyyyMMdd"
              placeholder="选择日期"
              style="width: 100%"
            ></el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="工作日期：" prop="workDate">
            <el-date-picker
              disabled
              v-model="formData.workDate"
              type="date"
              value-format="yyyyMMdd"
              placeholder="选择日期"
              style="width: 100%"
            ></el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="12">
          <el-form-item label="法人机构清算行行号：" prop="lpStBrno">
            <el-input v-model="formData.lpStBrno" placeholder="法人机构清算行行号" disabled />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="法人机构清算行行名：" prop="lpStBrnoName">
            <el-input v-model="formData.lpStBrnoName" placeholder="法人机构清算行行名" disabled />
          </el-form-item>
        </el-col>
      </el-row>

      <el-row type="flex">
        <el-col :span="12">
          <el-form-item label="管理类型：" prop="fpMngType">
            <el-select style="width: 100%" v-model="formData.fpMngType" placeholder="请选择" disabled>
              <el-option
                v-for="dict in dictMap.FP_MNG_TYPE"
                :key="dict.value"
                :label="`${dict.value}-${dict.text}`"
                :value="dict.value"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="分支机构数目：" prop="branchNum">
            <el-input v-model="formData.branchNum" placeholder="分支机构数目" disabled />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <el-divider v-if="formData.fpMngType != 'MT00'"></el-divider>
    <el-card class="form-card" v-if="formData.fpMngType == 'MT00'">
      <ht-table
        ref="formTable"
        :dictMap="dictMap"
        :multi-select="false"
        :initData="false"
        :queryParams="queryParamsDetail"
        :reqConfig="regConfigDetail"
        :showSerialNumber="false"
        :tableBindColumns="tableBindColumnsDetail"
        defaultEventKey="detailsTable"
      ></ht-table>
    </el-card>
    <br />
    <el-form ref="detailsForm" :model="formData" label-width="170px">
      <el-row type="flex">
        <el-col :span="12">
          <el-form-item label="录入操作员：" prop="mdTlrno">
            <el-input v-model="formData.mdTlrno" placeholder="录入操作员" disabled />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="录入时间：" prop="mdTime">
            <el-date-picker
              disabled
              v-model="formData.mdTime"
              type="datetime"
              value-format="yyyyMMddHHmmss"
              placeholder="选择时间"
              style="width: 100%"
            ></el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="24">
          <el-form-item label="审核附言：" prop="audRemarks">
            <el-input
              type="textarea"
              v-model="formData.audRemarks"
              placeholder="审核附言"
              maxlength="128"
              show-word-limit
            />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="approveFn" :loading="isLoading">审批</el-button>
      <el-button type="warning" @click="rejectFn" :loading="isLoading">拒绝</el-button>
    </div>
  </el-dialog>
</template>
<script>
import { searchTableapl, approve, reject } from "@/api/cnaps/saps/clearAcctPooling/clear_fundpool_approve.js";
import { log } from "util";
export default {
  name: "ApproveDetails",
  components: {},
  props: {
    dictMap: {
      type: Object,
      default: () => {
        return {};
      },
    },
    formData: {
      type: Object,
      default: () => {
        return {};
      },
    },
  },
  data() {
    return {
      regConfigDetail: searchTableapl,
      queryParamsDetail: {
        id: "",
      },
      tableBindColumnsDetail: [
        { label: `分支机构清算行行号`, prop: "branchStBrno", align: "center", sortable: false },
        { label: `分支机构清算行行名`, prop: "branchStBrnoName", align: "center", sortable: false },
      ],
      // 是否显示弹出层
      open: false,
      isLoading: false,
    };
  },
  watch: {
    open(val) {
      if (val) {
        if (this.formData.fpMngType == "MT00") {
          this.$set(this.queryParamsDetail, "id", this.formData.id);
          this.$nextTick(() => {
            this.$refs.formTable.doQuery();
          });
        }
      }
    },
  },
  mounted() {},
  methods: {
    // 审批方法
    approveFn() {
      this.isLoading = true;
      approve({ id: this.formData.id, audRemarks: this.formData.audRemarks })
        .then((res) => {
          this.isLoading = false;
          this.$emit("editComplete", true);
          this.msgSuccess("已审批!");
          this.closeFn();
        })
        .catch((err) => {
          this.isLoading = false;
        });
    },
    // 拒绝方法
    rejectFn() {
      this.isLoading = true;
      reject({ id: this.formData.id, audRemarks: this.formData.audRemarks })
        .then((res) => {
          this.isLoading = false;
          this.$emit("editComplete", true);
          this.msgSuccess("已拒绝!");
          this.closeFn();
        })
        .catch((err) => {
          this.isLoading = false;
        });
    },
    // 表单重置
    reset() {
      this.resetForm("detailsForm");
      // this.$set(this, "form", {});
    },
    closeFn() {
      this.open = false;
      this.reset();
    },
    show() {
      this.open = true;
    },
  },
};
</script>
<style lang="scss" scoped>
.label-header-msg {
  font-weight: bold;
}

.form-card {
  margin-bottom: 10px;
}
</style>
